﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title>RefrenceEdit</title>
	<script type="text/javascript" src="../../Scripts/jquery-1.4.1.min.js"></script>
	<script type="text/javascript" src="../../Scripts/jquery.jbind.js"></script>
	<script type="text/javascript" src="../../Scripts/jquery.treeTable.js"> </script>
	<script src="../../Scripts/jquery.easyui.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../Scripts/jquery.FixedHeadTable.js"> </script>
	<link href="../../Content/jquery.treeTable.css" rel="stylesheet" type="text/css" />
	<link href="../../Content/easyui.css" rel="stylesheet" type="text/css" />
	<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
	<script src="../../Scripts/kindeditor-all-min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../Scripts/kindeditor_zh_cn.js"></script>
	<link rel="stylesheet" href="../../Content/kindeditor_default/default.css" />
	<script type="text/javascript">

		var editor;
		KindEditor.ready(function (K) {
			editor = K.create('textarea[name="Content"]', {
				resizeType: 1,
				allowPreviewEmoticons: true,
				allowImageUpload: true,
				allowFileManager: true,
				allowUpload: true,
				fileManagerJson: '/Admini/UploadImage',
				uploadJson: '/Admini/UploadImage',
				items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
						'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
						'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
						'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
						'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
						'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
						 'table', 'hr', 'pagebreak',
						'anchor', 'link', 'unlink', '|', 'about']
			});
		});
		$(document).ready(function () {
			var id = $("#ID").val();
			alert(id);
			if (id != "") {
				$.ajax({
					url: "/Admini/GetReferenceByID",
					data: { id: id },
					cache: false,
					success: function (data) {
						if (data != null) {
							$("#year").val(data.RYear);
							$("#productname").val(data.ProjectName);
							$("#city").val(data.City);
							editor.insertHtml(data.Description);
						}
					},
					error: function (data) { }
				});
			}
		});

		function save() {

			var id = $("#ID").val();
			if (id == "") {
				id = 0;
			}
			var year = $("#year").val();
			var productname = $("#productname").val();
			var city = $("#city").val();
			var desc = editor.html();
			$.ajax({
				url: "/Admini/SaveReference",
				cache: false,
				data: { id: id, year: year, projectName: productname, city: city, description: desc },
				success: function () {
					alert("Reference has Saved");
					location.href("/Admini/Reference");
				},
				error: function (data) {
				}
			});
		}
		function cancel() {
			location.href("/Admini/Reference");
		}
	</script>
</head>
<body>
	<div style="width: 100%">
		<input type="hidden" name="name" value=" " />
		<input type="hidden" name="name" id="ID" value="<%=ViewData["id"] %>" />
		Year:<input type="text" name="name" id="year" value="" />
		ProjectName:<input type="text" name="name" id="productname" value="" />
		City:<input type="text" name="name" id="city" value="" />
		<input type="button" name="name" value="Save" onclick="save()" />
		<input type="button" name="name" value="Cancel" onclick="cancel()" />
		<div>
			<textarea id="txtContent" name="Content" cols="80" rows="40"></textarea>
		</div>
	</div>
</body>
</html>
